<?php
namespace Anls\Controller;
use Think\Controller;
use Anls\Com\File;
use Anls\Common\AbstractCommonBaseController;
use Anls\Common;
use Anls\Common\Log;

/**
 * 模块公共抽象类
 * @author wsf
 *
 */
abstract class AbstractTradeSupportController extends AbstractCommonBaseController {
	
    public function _initialize(){
        parent::_initialize();
    }
    
    /**
     * 获取过滤代码
     */
    protected function getFilterCodes(){
        $cacheFilterCodes = $this->redis->lRange(Common\Redis::$FILTER_CODES_KEY, 0, -1);
        $filterCodes = array();
        if($cacheFilterCodes == null){
            // 获取过滤代码文件
            $filterFileList = File\FileHandle::getFilterFiles();
            $cnt = count($filterFileList);
            for($i=0;$i<$cnt;$i++){
                // 获取文件名
                $fileName = $filterFileList[$i];
                $filterCodes[$fileName] = 1;
                $this->redis->rPush(Common\Redis::$FILTER_CODES_KEY,$fileName);
            }
        } else {
            $cnt = count($cacheFilterCodes);
            for($i=0;$i<$cnt;$i++){
                $filterCodes[$cacheFilterCodes[$i]] = 1;
            }
        }
        return $filterCodes;
    }
    
}